home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Sessions / Completions / Presentation Code / SimplifiedCatInfo.cp < prev    next >
Encoding:
Text File  |  1998-06-19  |  980 b   |  58 lines  |  [TEXT/CWIE]

  1.  
  2. class CatInfoChanger: private Task,
  3.                              public CInfoPBRec
  4.   {
  5.     private:
  6.         bool getting;
  7.         
  8.         virtual void Launch();
  9.         virtual void Kill();
  10.  
  11.         static void Complete( CInfoPBRec *block );
  12.  
  13.     public:
  14.         CatInfoChanger();
  15.         
  16.         Task *Get( const FSSpec& );
  17.         Task *Set( const FSSpec& );
  18.   };
  19.  
  20.  
  21. CatInfoChanger::CatInfoChanger()
  22.   {
  23.     hFileInfo.ioCompletion = &CompleteGlue;
  24.     hFileInfo.ioResult = noErr;
  25.   }
  26.  
  27.  
  28. Task *CatInfoChanger::Get( const FSSpec& location )
  29.   {    
  30.     hFileInfo.ioVRefNum = location.vRefNum;
  31.     hFileInfo.ioDirID = location.parID;
  32.     hFileInfo.ioNamePtr = const_cast<StringPtr>( location.name );
  33.     hFileInfo.ioFDirIndex = 0;
  34.     getting = true;
  35.         
  36.     return this;
  37.   }
  38.  
  39.  
  40. void CatInfoChanger::Launch()
  41.   {
  42.     if ( getting )
  43.         PBGetCatInfoAsync( this );
  44.      else
  45.         PBSetCatInfoAsync( this );         
  46.   }
  47.  
  48. void CatInfoChanger::Kill()
  49.   {
  50.   }
  51.  
  52. void CatInfoChanger::Complete( CInfoPBRec *block )
  53.   {
  54.     CatInfoChanger *self = static_cast< CatInfoChanger * >( block );
  55.     self->Task::Complete();
  56.   }
  57.  
  58.